package com.tsite.service.common.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

import com.tsite.dao.IUserDAO;
import com.tsite.entity.User;

@Component
public class UserDetailsServiceImpl implements UserDetailsService {

	@Autowired
	private IUserDAO userDao;
	
	@Override
	public UserDetails loadUserByUsername(String username)
			throws UsernameNotFoundException {
		User user = userDao.selectUserByName(username);
		if(user != null)
			return new UserDetailsImpl(user);
		return null;
	}

}
